#pragma once
#include "Vector3.h"
 class Camera
{
public:
	Camera()
	{
		aspectRatio = 1.0f;
		position = D3DXVECTOR3(0, 0, 0);
	}
	virtual ~Camera();
public: 
	char * Name;
	float aspectRatio;
	D3DVIEWPORT9 mViewPort;
	D3DXVECTOR3 position;


	virtual void Project(LPDIRECT3DDEVICE9 device)
	{
		TransformProjectionMatrix(device);

		//	Get the matrix.
		device->GetTransform(D3DTS_PROJECTION, &m_ProjectionMatrix);
	}

	virtual void TransformProjectionMatrix(LPDIRECT3DDEVICE9 gl)  = 0;

	virtual double Distance()
	{
		return 0;
	}

	void ComputeMatrix(LPDIRECT3DDEVICE9 m_Device3d)
	{
		m_Device3d->GetTransform(D3DTS_WORLD, &m_WorldMatrix);
		m_Device3d->GetTransform(D3DTS_PROJECTION, &m_ProjectionMatrix);
		m_Device3d->GetTransform(D3DTS_VIEW, &m_ViewMatrix);
		m_Device3d->GetViewport(&mViewPort);
	}

	D3DXVECTOR3 Project(D3DXVECTOR3 point)
	{
		D3DXVECTOR3 pointOut;
		D3DXVec3Project(&pointOut,&point, &mViewPort, &m_ProjectionMatrix, &m_ViewMatrix , &m_WorldMatrix );//m_ProjectionMatrix * m_ViewMatrix * m_WorldMatrix
		return point;
	}

	D3DXVECTOR3 UnProject(D3DXVECTOR3 point)
	{
		D3DXVECTOR3 v2;
		D3DXVec3Unproject(&v2, &point, &mViewPort, &m_ProjectionMatrix, &m_ViewMatrix, &m_WorldMatrix);
		return v2;
	}

	D3DXMATRIX m_ProjectionMatrix;
	D3DXMATRIX m_ViewMatrix;
	D3DXMATRIX m_WorldMatrix;
	
};

